/*
 *  $Id: MercilessFire.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Fire.Spells {
    public class MercilessFire: SelfEnchantmentCard {
        public MercilessFire(): base("001_f_s_merciless_fire") {
            Level = CompleteLevel.ReadyForTest;
            Version = 0;
            Element = ElementType.Fire;
            Value = 100;
            AddManaCost(ElementType.Fire, 2);
        }

        protected override EnchantmentAffect CreateEnchantment() {
            return new MercilessFireAffect();
        }

        private class MercilessFireAffect: EnchantmentAffect<MercilessFire> {}

        public static int DoFireDamage(Player caster, SpellCard spell, Creature target, int damage) {
            int dmg = target.DamageBy(spell.NewDamage(caster, damage));
            if (!target.IsDeath) {
                int count = 0;
                foreach (Affect affect in caster.GetAffects(false))
                    if (affect is MercilessFireAffect)
                        count++;
                while (count > 0) {
                    target.AddAffect(new Affects.Scorch(1));
                    count--;
                }
            }
            return dmg;
        }
    }
}
